//
//  WaiSongViewController.m
//  FD
//
//  Created by Yasin on 2018/10/13.
//  Copyright © 2018年 ZhiYuan Network. All rights reserved.

#import "WaiSongViewController.h"
#import "WSSureOrderViewController.h"

@interface WaiSongViewController ()

@end

@implementation WaiSongViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];

    //自定义导航栏
    [self createNav];
    
    FDWeakSelf;
    self.clickJieSuanActionBlock = ^{
            WSSureOrderViewController *sureorderVC = [[WSSureOrderViewController alloc] init];
            [weakSelf.navigationController pushViewController:sureorderVC animated:YES];
    };
}





#pragma mark - 自定义导航条
// 创建“导航栏”
- (void)createNav{
    
    // 在主线程异步加载，使下面的方法最后执行，防止其他的控件挡住了导航栏
    dispatch_async(dispatch_get_main_queue(), ^{
        //=========右边的按钮===========
        UIButton *rightMyKaQuanBtn = [UIButton buttonWithType:(UIButtonTypeCustom)];
        
        
        NSString *kaQuanStr = NSLocalizedString(My_kaQuan, @"我的卡券");
        [rightMyKaQuanBtn setTitle:kaQuanStr forState:(UIControlStateNormal)];
        rightMyKaQuanBtn.frame = CGRectMake(0, 0, 100, 30); //不给frame iphone5真机有问题
        rightMyKaQuanBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
        
        [rightMyKaQuanBtn setTitleColor:[UIColor redColor] forState:(UIControlStateNormal)];
        [rightMyKaQuanBtn addTarget:self action:@selector(clickRightMyKaQuanAction:) forControlEvents:(UIControlEventTouchUpInside)];
        self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:rightMyKaQuanBtn];
    });
}

// 点击了 导航啦栏右侧的我的卡券
- (void)clickRightMyKaQuanAction:(UIButton *)btn {
    MyKaQuanViewController *myKaQuanVC = [[MyKaQuanViewController alloc] init];
    [self.navigationController pushViewController:myKaQuanVC animated:YES];
}

@end
